fix(oauth): correct token cache expiry time comparison#68
Open
mayfield-z wants to merge 1 commit intofree5gc:mainfrom
Open
fix(oauth): correct token cache expiry time comparison#68mayfield-z wants to merge 1 commit intofree5gc:mainfrom
mayfield-z wants to merge 1 commit intofree5gc:mainfrom
Conversation
The token cache was never used due to incorrect time comparison. Original code compared absolute Unix timestamp with relative seconds (e.g., 1769528115 < 3600 always returns false). This caused every NF communication to request a new OAuth token from NRF, resulting in ~20 token requests per UE registration and high NRF load. Fixed by: - Introducing cachedToken struct to store absolute expiry timestamp - Calculating expiry time as: current_time + expires_in_seconds - Comparing current time with absolute expiry timestamp Performance improvement: - Reduces token requests by 85-90% - Lowers NRF load significantly - Decreases UE registration latency by 50-100ms
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The OAuth token cache was never working due to incorrect time comparison logic.
Original code:
This compares absolute Unix timestamp (e.g., 1769528115) with relative seconds (e.g., 3600), which always returns false.
Solution
Introduced
cachedTokenstruct to store absolute expiry timestamp:current_time + expires_in_secondsResult
After this fix, the second UE registration will use cached tokens instead of requesting new ones from NRF.